home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD World 1998 January
/
CD World - Ocak 1998.iso
/
misc
/
dbase55
/
disk7
/
samples1.pak
/
CONTACT.WFM
< prev
next >
Wrap
Text File
|
1995-07-18
|
18KB
|
653 lines
*******************************************************************************
* PROGRAM: Contact.wfm
*
* WRITTEN BY: Borland Samples Group
*
* DATE: 5/93
*
* UPDATED: 5/95
*
* REVISION: $Revision: 2.63 $
*
* VERSION: Visual dBASE
*
* DESCRIPTION: The form in this file displays a list of companies and
* lets you view the contacts for those companies in a separate
* form. It contains a listbox of company names, 3 radiobuttons
* indicating the company's type, and pushbuttons that allow you
* to see the form with contacts for the currently hightlighted
* company or leave the contact form.
* The third page of this form allows you to create a link to
* Word 6 using Ole Automation, and, using the Mail Merge feature
* of Word, create letters to the companies in the Company table.
*
* PARAMETERS: None
*
* CALLS: Buttons.cc (Custom Controls file)
* Contact.qbe (View of tables)
*
* USAGE: DO Contact.wfm
*
*******************************************************************************
#include <Messdlg.h>
* Word basic function parameter values
#define REPORT_ERRORS 1
#define TO_FILE 0
#define TO_PRINTER 1
#define MERGE_ALL 0
#define MERGE_RANGE 1
#define NO_SAVE 2
#define PRINT_PREVIEW_OFF 0
#define PRINT_PREVIEW_ON 1
shell(.F.)
create session
set talk off
set ldCheck off
** END HEADER -- do not remove this line*
* Generated on 07/11/95
*
parameter bModal
local f
f = new CONTACTFORM()
if (bModal)
f.mdi = .F. && ensure not MDI
f.ReadModal()
else
f.Open()
endif
CLASS CONTACTFORM OF FORM
Set Procedure To &_dbwinhome.samples\BUTTONS.CC additive
this.OnOpen = CLASS::FORM_ONOPEN
this.EscExit = .F.
this.Width = 55.666
this.OnClose = CLASS::FORM_ONCLOSE
this.View = "CONTACT.QBE"
this.Text = "Contact"
this.Top = 1.1172
this.Maximize = .F.
this.Minimize = .F.
this.Left = 25
this.ColorNormal = "BTNTEXT/BTNFACE"
this.MousePointer = 1
this.Height = 12.5293
this.PageNo = 1
DEFINE TEXT LISTTEXT OF THIS;
PROPERTY;
Width 17.166,;
FontBold .F.,;
Text "Company Name:",;
Top 0.8262,;
Left 0.5,;
ColorNormal "B/BtnFace",;
PageNo 0,;
Height 1.1143
DEFINE LISTBOX COMPANYLIST OF THIS;
PROPERTY;
DataSource "FIELD COMPANY->COMPANY",;
Width 24.833,;
FontBold .F.,;
ID 800,;
Top 2,;
ColorHighLight "W+/B",;
Left 0.5,;
ColorNormal "N/W*",;
Height 7
DEFINE TEXT TYPETEXT OF THIS;
PROPERTY;
Width 17.166,;
FontBold .F.,;
Text "Company Type:",;
Top 2.1797,;
Left 0.5,;
ColorNormal "B/BtnFace",;
PageNo 2,;
Height 0.9961
DEFINE RADIOBUTTON COMPANYTYPE1 OF THIS;
PROPERTY;
Width 8,;
Group .T.,;
Text "OEM",;
Top 2.1758,;
Enabled .F.,;
DataLink "COMPANY->TYPE",;
Left 17,;
ColorNormal "N/BtnFace",;
PageNo 2,;
Height 1
DEFINE RADIOBUTTON COMPANYTYPE2 OF THIS;
PROPERTY;
Width 7,;
Group .F.,;
Text "ISV",;
Top 2.1973,;
Enabled .F.,;
DataLink "COMPANY->TYPE",;
Left 26,;
ColorNormal "N/BtnFace",;
PageNo 2,;
Height 0.9775
DEFINE RADIOBUTTON COMPANYTYPE3 OF THIS;
PROPERTY;
Width 8.002,;
Group .F.,;
Text "VAR",;
Top 2.1973,;
Enabled .F.,;
DataLink "COMPANY->TYPE",;
Left 33.8311,;
ColorNormal "N/BtnFace",;
PageNo 2,;
Height 0.9775
DEFINE TEXT CONTACTTEXT OF THIS;
PROPERTY;
Width 19.833,;
FontBold .F.,;
Text "Contact:",;
Top 0.8262,;
Left 28.5,;
ColorNormal "B/BtnFace",;
Height 1.1143
DEFINE ENTRYFIELD CONTACTENTRY OF THIS;
PROPERTY;
Width 26.166,;
FontBold .F.,;
Function "S80",;
Top 2,;
ColorHighLight "B+/W*",;
Enabled .F.,;
DataLink "CONTACT->CONTACT",;
Left 28.5,;
ColorNormal "B/W*",;
Height 1.1172
DEFINE TEXT NOTESTEXT OF THIS;
PROPERTY;
Width 11.8359,;
FontBold .F.,;
Text "Notes:",;
Top 3.5,;
Left 28.6641,;
ColorNormal "B/BtnFace",;
Height 0.8516
DEFINE EDITOR EDITNOTES OF THIS;
PROPERTY;
Width 26.166,;
FontBold .F.,;
CUATab .T.,;
Modify .F.,;
Top 4.5,;
DataLink "CONTACT->NOTES",;
Left 28.5,;
ColorNormal "N/W*",;
Height 4.4395
DEFINE CLOSEBUTTON CONTACTCLOSEBUTTON OF THIS;
PROPERTY;
Width 14.1689,;
Group .T.,;
Top 9.6973,;
Left 40.6641,;
PageNo 0,;
Height 1.5361
DEFINE TABBOX CONTACTTABBOX OF THIS;
PROPERTY;
DataSource 'ARRAY {"Contact","Company","Mail Merge"}',;
Width 55.666,;
FontBold .F.,;
ID 112,;
Top 11.5293,;
ColorHighLight "BtnText/BtnFace",;
ColorNormal "R/BTNFACE",;
OnSelChange CLASS::CONTACTTABBOX_ONSELCHANGE,;
Height 1
DEFINE ENTRYFIELD COMPANYENTRY OF THIS;
PROPERTY;
Width 36.502,;
FontBold .F.,;
Top 0.8262,;
Enabled .F.,;
DataLink "COMPANY->COMPANY",;
Left 17.3311,;
ColorNormal "B/WINDOW",;
PageNo 2,;
Height 0.9971
DEFINE RECTANGLE RECTANGLE1 OF THIS;
PROPERTY;
Width 54.333,;
Text "",;
Top 3.8223,;
Left 0.5,;
PageNo 2,;
Height 5.5303
DEFINE TEXT STREETTEXT OF THIS;
PROPERTY;
Width 8,;
FontBold .F.,;
Text "Street:",;
Top 4.5,;
Left 2.5,;
ColorNormal "B/BtnFace",;
PageNo 2,;
Height 1.0293
DEFINE TEXT CITYTEXT OF THIS;
PROPERTY;
Width 5.5,;
FontBold .F.,;
Text "City:",;
Top 6.8975,;
Left 2.5,;
ColorNormal "B/BtnFace",;
PageNo 2,;
Height 0.748
DEFINE ENTRYFIELD STREET1ENTRY OF THIS;
PROPERTY;
Width 43.5,;
FontBold .F.,;
Top 4.5,;
Enabled .F.,;
DataLink "COMPANY->STREET1",;
Left 10.5,;
ColorNormal "N/WINDOW",;
PageNo 2,;
Height 1.0293
DEFINE ENTRYFIELD STREET2ENTRY OF THIS;
PROPERTY;
Width 43.5,;
FontBold .F.,;
Top 5.5977,;
Enabled .F.,;
DataLink "COMPANY->STREET2",;
Left 10.5,;
ColorNormal "N/WINDOW",;
PageNo 2,;
Height 0.9902
DEFINE ENTRYFIELD CITYENTRY OF THIS;
PROPERTY;
Width 14.166,;
FontBold .F.,;
Top 6.8975,;
Enabled .F.,;
DataLink "COMPANY->CITY",;
Left 10.5,;
ColorNormal "N/WINDOW",;
PageNo 2,;
Height 0.9844
DEFINE ENTRYFIELD STATEPROVINCEENTRY OF THIS;
PROPERTY;
Width 12.6689,;
FontBold .F.,;
Top 6.8975,;
Enabled .F.,;
DataLink "COMPANY->STATE_PROV",;
Left 41.3311,;
ColorNormal "N/WINDOW",;
PageNo 2,;
Height 0.9844
DEFINE ENTRYFIELD ZIPPOSTALENTRY OF THIS;
PROPERTY;
Width 11.666,;
FontBold .F.,;
Function "J",;
Top 8.1973,;
Enabled .F.,;
DataLink "COMPANY->ZIP_P_CODE",;
Left 26,;
ColorNormal "N/WINDOW",;
PageNo 2,;
Height 0.9775
DEFINE TEXT STATEPROVINCETEXT OF THIS;
PROPERTY;
Width 15,;
FontBold .F.,;
Text "State/Province:",;
Top 6.8975,;
Left 26,;
ColorNormal "B/BtnFace",;
PageNo 2,;
Height 0.748
DEFINE TEXT ZIPPOSTALTEXT OF THIS;
PROPERTY;
Width 11,;
FontBold .F.,;
Text "Zip/Postal:",;
Top 8.1973,;
Left 14,;
ColorNormal "B/BtnFace",;
PageNo 2,;
Height 0.9775
DEFINE ENTRYFIELD COMPANYENTRY2 OF THIS;
PROPERTY;
Width 36.502,;
FontBold .F.,;
Top 0.8262,;
Enabled .F.,;
DataLink "COMPANY->COMPANY",;
Left 17.3311,;
ColorNormal "B/WINDOW",;
PageNo 3,;
Height 0.9971
DEFINE TEXT SENDTTOEXT OF THIS;
PROPERTY;
Width 25.5,;
FontBold .F.,;
Text "Send 'Thank You' letter to ",;
Left 0.5,;
ColorNormal "B/BtnFace",;
PageNo 3,;
Height 0.7637
DEFINE RECTANGLE RADIORECT OF THIS;
PROPERTY;
Width 55,;
FontBold .F.,;
Text "Send To: ",;
Top 4,;
Left 0.5,;
ColorNormal "B/BtnFace",;
PageNo 3,;
Height 3.5293
DEFINE RADIOBUTTON PRINTERRADIO OF THIS;
PROPERTY;
Width 15,;
FontBold .F.,;
Group .T.,;
Text "Printer",;
Top 5,;
Left 8,;
ColorNormal "B/BtnFace",;
OnChange CLASS::PRINTERRADIO_ONCHANGE,;
PageNo 3,;
Value .T.,;
Height 1.1172
DEFINE RADIOBUTTON FILERADIO OF THIS;
PROPERTY;
Width 9.666,;
FontBold .F.,;
Group .F.,;
Text "File",;
Top 6,;
Left 8,;
ColorNormal "B/BtnFace",;
OnChange CLASS::FILERADIO_ONCHANGE,;
PageNo 3,;
Value .F.,;
Height 1.1172
DEFINE ENTRYFIELD FILENAMEENTRY OF THIS;
PROPERTY;
Width 32,;
FontBold .F.,;
Visible .F.,;
Top 6,;
Enabled .F.,;
Left 18,;
ColorNormal "B+/Window",;
PageNo 3,;
Value "FILENAMEENTRY",;
Height 1
DEFINE TOOLBUTTON FILETOOLBUTTON OF THIS;
PROPERTY;
Width 4,;
Group .T.,;
Visible .F.,;
Top 6,;
Left 51,;
OnClick CLASS::FILETOOLBUTTON_ONCLICK,;
PageNo 3,;
Height 1
DEFINE CHECKBOX ALLCOMPSCHECK OF THIS;
PROPERTY;
Width 30.833,;
FontBold .F.,;
Group .T.,;
Text "Create letters for all companies",;
Top 2.5,;
Left 0.5,;
ColorNormal "B/BtnFace",;
PageNo 3,;
Value .F.,;
Height 1.1465
DEFINE PUSHBUTTON RUNMAILMERGEBUTTON OF THIS;
PROPERTY;
Width 14.166,;
Group .T.,;
Text "Mail Merge",;
Top 9.6973,;
SpeedTip "Run Word, and create letter",;
Left 24,;
OnClick CLASS::RUNMAILMERGEBUTTON_ONCLICK,;
PageNo 3,;
UpBitmap "RESOURCE #108",;
Height 1.5361
DEFINE CHECKBOX PRINTPREVIEWCHECK OF THIS;
PROPERTY;
Width 31.666,;
FontBold .F.,;
Group .T.,;
Text "Preview Printed Document",;
Top 5,;
Enabled .F.,;
Left 18,;
ColorNormal "B/BtnFace",;
PageNo 3,;
Value .T.,;
Height 1
DEFINE SAMPLEINFOBUTTON CONTACTINFOBUTTON OF THIS;
PROPERTY;
Width 3.5,;
Group .T.,;
Top 10,;
Left 0.5,;
Height 1.1758
Procedure Form_OnOpen
****************************************************************************
form.wordApp = "" && Reference to word
&& Default file name for saving Mail Merge doc
form.fileNameEntry.value = setto("directory") + "\Compltrs.doc"
form.contactInfoButton.sampleName = "Contact.wfm"
form.contactCloseButton.SetFocus()
****************************************************************************
Procedure Form_OnClose
****************************************************************************
if CLASS::IsWordOpen() && Word was left open
if ConfirmationMessage("Close Word, and discard latest changes?", "Confirm") = YES
form.wordApp.FileCloseAll(NO_SAVE)
form.wordApp.AppClose()
endif
endif
close procedure &_dbwinhome.samples\Buttons.cc
****************************************************************************
Procedure CONTACTTABBOX_OnSelChange
****************************************************************************
form.pageNo = this.curSel
****************************************************************************
Procedure FILERADIO_OnChange
****************************************************************************
if this.value
form.printerRadio.value = .F.
form.printPreviewCheck.visible = .F.
form.fileNameEntry.visible = .T.
form.fileToolButton.visible = .T.
endif
****************************************************************************
Procedure PRINTERRADIO_OnChange
****************************************************************************
if this.value
form.fileRadio.value = .F.
form.fileNameEntry.visible = .F.
form.fileToolButton.visible = .F.
form.printPreviewCheck.visible = .T.
endif
****************************************************************************
Procedure FILETOOLBUTTON_OnClick
****************************************************************************
private fileName, name, extension, periodLoc
fileName = putFile("Type the name of a file for saving merged letter(s)",;
"*.doc")
if .not. empty(fileName) && a name was actually selected
form.fileNameEntry.value = fileName
show object form.fileNameEntry
endif
****************************************************************************
Procedure RUNMAILMERGEBUTTON_OnClick
****************************************************************************
private destination, mergeRecords, recNo
if empty(form.wordApp) && Word has not been opened yet
if ConfirmationMessage("You must have a dBASE ODBC driver installed " +;
"for this mail merge to work properly. " +;
"Continue?",;
"Confirm") = YES
on error AlertMessage(message(), "Sorry")
form.wordApp = new oleautoclient("word.basic") && Open Word
on error
if empty(form.wordApp)
InformationMessage("You need to have MS Word 6.0 or greater " +;
"installed on your machine to run Mail Merge.",;
"Sorry")
endif
endif
endif
if .not. empty(form.wordApp) && Word has already been opened
if .not. CLASS::IsWordOpen() && Make sure Word wasn't closed down
form.wordApp = new oleAutoClient("word.basic")
endif
if .not. CLASS::IsWindowOpen("COMPANY.DOC")
if .not. file("Company.doc") && Make sure Company.doc exists
InformationMessage("Company.doc doesn't exist. It is " +;
" necessary for running this Mail Merge.",;
"Info")
else
form.wordApp.FileOpen("COMPANY.DOC") && Open generic document
endif
endif
if CLASS::IsWindowOpen("COMPANY.DOC") && If Company.doc was opened
form.wordApp.Activate("COMPANY.DOC")
&& Attach Company.dbf as source
form.wordApp.MailMergeOpenDataSource("Company.dbf")
if form.allCompsCheck.value && If letters to all companies
mergeAll = 0
recNo = 0
else
mergeAll = 1
recNo = recno() && Only current Company
endif
&& Set mail merge options
form.wordApp.MailMerge(REPORT_ERRORS, TO_FILE, mergeAll, recNo, recNo)
form.wordApp.MailMergeToDoc() && Start with a file
if form.printerRadio.value && If printing letters
if ConfirmationMessage("Print Document?", "Confirm") = YES
form.wordApp.FilePrintDefault() && Print with default options
endif
else && If saving to file
form.wordApp.FileSaveAs(form.fileNameEntry.value)
endif
endif
endif
****************************************************************************
Function IsWordOpen
****************************************************************************
private fWordOpen
fWordOpen = .F.
if .not. empty(form.wordApp)
* If Word was opened, and handle to it exists
if (type("form.wordApp.WdGetHWnd") <> "U") .and.;
(form.wordApp.WdGetHWnd() > 0)
fWordOpen = .T.
endif
endif
return fWordOpen
****************************************************************************
Function IsWindowOpen(name)
****************************************************************************
private windowOpen, i, windowCnt
windowCnt = form.wordApp.CountWindows()
windowOpen = .F.
for i = 1 to windowCnt
if form.wordApp.WindowName(i) = name
windowOpen = .T.
endif
next i
return windowOpen
ENDCLASS